If exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[CheckDelegateStatus]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[CheckDelegateStatus]
GO
/******************************************************************          
* Name:   [CheckForDelegateStatus]          
* Purpose:  Identifies whether or not the logged in person is a delegate

* PARAMETERS          
* Name          Description               
* -------------      -------------------------------------------          
* @delegateId    Admin person Id (REQUIRED) to identify, if the user is a delegate           
*********************************************************************/ 
CREATE PROC dbo.[CheckDelegateStatus]
(
	@delegateId int
)
AS 
SET NOCOUNT ON
BEGIN
	Select Case Count(SupervisorId)
				when  0 then 0
				Else  1
				End
	 as IsDelegate from COI_Delegate_Map 
	 where 
	 Removed = 0 
	 AND
	 DelegateId = @delegateId
END

